import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import { postRequest, getRequest, putRequest, deleteRequest} from './utils/api';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import 'font-awesome/css/font-awesome.css'
import { initMenu } from './utils/menus'

Vue.config.productionTip = false
Vue.prototype.postRequest = postRequest;
Vue.prototype.getRequest = getRequest;
Vue.prototype.putRequest = putRequest;
Vue.prototype.deleteRequest = deleteRequest;
Vue.use(ElementUI)

router.beforeEach((to, from, next) => {
  if(window.sessionStorage.getItem('tokenStr')){
    initMenu(router, store);
    next();
  }else{
    next();
  }
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
